import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  lang: localStorage.getItem("my-lang") || "zh",
};

export const langSlice = createSlice({
  name: "LANG",
  initialState,
  reducers: {
    setLang(state, action) {
      state.lang = action.payload;
    },
  },
});

export const { setLang } = langSlice.actions;
export const selectLang = (state: any) => state.mylang.lang;

export default langSlice.reducer;
